<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>油品信息管理</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: url('/images/2.jpg') no-repeat center center fixed;
            background-size: cover;
            font-family: "微软雅黑", sans-serif;
        }

        /* 主体内容区域样式 */
        .main-content {
            margin-left: 200px;
            padding: 20px;
            background-color: rgba(255, 255, 255, 0.5);
            min-height: calc(100vh - 50px);
        }

        .breadcrumb {
            margin-bottom: 20px;
            color: #0e0e0e;
        }

        .breadcrumb a {
            color: #0e0e0e;
            text-decoration: none;
        }

        .breadcrumb a:hover {
            text-decoration: underline;
        }

        /* 搜索栏样式 */
        .search-bar {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }
        .search-bar label {
            margin-right: 10px;
        }
        .search-bar input {
            padding: 5px 8px;
            border: 1px solid #ccc;
            border-radius: 3px;
            margin-right: 10px;
        }
        .search-bar button {
            padding: 5px 15px;
            background-color: #1773d0;
            color: #fff;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }

        /* 按钮组样式 */
        .btn-group {
            margin-bottom: 15px;
        }
        .btn-group button, .btn-group a {
            padding: 6px 12px;
            margin-right: 10px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            color: #fff;
            text-decoration: none;
            display: inline-block;
        }
        .btn-add {
            background-color: #5cb85c; /* 新增按钮颜色 */
        }
        .btn-delete {
            background-color: #d9534f; /* 删除按钮颜色 */
        }

        /* 表格样式 */
        .table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 10px;
        }
        .table thead {
            background-color: #902d2d;
            color: #fff;
        }
        .table th, .table td {
            border: 1px solid #ddd;
            padding: 8px 10px;
            text-align: center;
        }
        .table tbody tr:nth-child(even) {
            background-color: #f9f9f9;
        }

        /* 操作按钮样式 */
        .operate-btn {
            padding: 4px 8px;
            margin: 0 2px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            color: #fff;
            text-decoration: none;
            display: inline-block;
        }
        .btn-edit {
            background-color: #f0ad4e; /* 修改按钮 */
        }
        .btn-remove {
            background-color: #d9534f; /* 删除按钮 */
        }

        /* 公共组件样式继承 */
        .top-nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #9b2222;
            color: #fff;
            padding: 10px 20px;
        }
        .top-nav-left { font-size: 16px; }
        .top-nav-middle { font-size: 20px; font-weight: bold; }
        .top-nav-right span { margin-left: 15px; cursor: pointer; }

        .sidebar {
            width: 200px;
            background-color: #fff;
            float: left;
            height: calc(100vh - 50px);
            padding-top: 20px;
            position: relative;
            border-right: 1px solid #eee;
        }
        .sidebar ul { list-style: none; }
        .sidebar li {
            padding: 12px 20px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        .sidebar li:hover { background-color: #ddd; }
        .sidebar li a {
            text-decoration: none;
            color: inherit;
            display: block;
        }
        .sidebar li.active {
            background-color: #ddd;
            font-weight: bold;
        }
    </style>
</head>
<body>
<!-- 引入公共导航 -->
<div th:replace="~{common/common::topbar}"></div>
<div th:replace="~{common/common::sidebar}"></div>

<div class="main-content">
    <!-- 面包屑导航 -->
    <div class="breadcrumb">
        <a href="/login.html">系统首页</a> > 油品信息管理
    </div>

    <!-- 搜索栏 -->
<!--    <div class="search-bar">-->
<!--        <label for="searchInput">搜索：</label>-->
<!--        <input type="text" id="searchInput" name="name" placeholder="请输入油品名称">-->
<!--        <button type="submit">查询</button>-->
<!--    </div>-->

    <form id="searchForm" action="/oil_info/search" method="get" class="search-bar">
        <label for="searchInput">搜索：</label>
        <input type="text" id="searchInput" name="name" placeholder="请输入油品名称">
        <button type="submit">查询</button>
    </form>

    <!-- 按钮组 -->
    <div class="btn-group">
        <a th:href="@{/oil_info/add}" class="btn-add">新增</a>
        <button class="btn-delete">删除选中</button>
    </div>

    <!-- 数据表格 -->
    <table class="table">
        <thead>
        <tr>
            <th><input type="checkbox"></th>
            <th>ID</th>
            <th>油品名称</th>
            <th>库存量</th>
            <th>单价(元)</th>
            <th>更新时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="oil : ${oilLists}">
            <td><input type="checkbox"></td>
            <td th:text="${oil.id}"></td>
            <td th:text="${oil.oilName}"></td>
            <td th:text="${oil.stock}"></td>
            <td th:text="${oil.unitPrice}"></td>
            <td th:text="${#dates.format(oil.updateTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
            <td>
                <a th:href="@{/oil_info/edit/{id}(id=${oil.id})}" class="operate-btn btn-edit">修改</a>
                <a th:href="@{/oil_info/delete(id=${oil.id})}" class="operate-btn btn-remove"
                   onclick="return confirm('确定删除吗？')">删除</a>
            </td>
        </tr>
        <tr th:if="${oilLists == null or oilLists.isEmpty()}">
            <td colspan="7" class="text-center">暂无数据</td>
        </tr>
        </tbody>
    </table>
</div>

<script>
    // 设置侧边栏激活状态
    document.addEventListener('DOMContentLoaded', function() {
        const sidebarItems = document.querySelectorAll('.sidebar li a');
        sidebarItems.forEach(item => {
            if (item.getAttribute('href') === '/oil_info/list') {
                item.parentElement.classList.add('active');
            }
        });
    });
</script>
</body>
</html>